classdef OutputPort < MeasurementComponent.MachineUnit.IOPort.AbstractPort
    %@OUTPUTPORT 
    
    properties
        driver
    end
    
    %%
    methods
        function obj = OutputPort(device, name)
            obj@MeasurementComponent.MachineUnit.IOPort.AbstractPort(device, name, 'output');
            obj.driver = [];
        end
        function setDriver(obj, drv)
            L = log4m.getLogger;
            prv_drv = obj.driver;
            obj.driver = drv;
            
            if isempty(prv_drv)
                prv_drv_name = 'n.a.';
            else
                prv_drv_name = prv_drv.name;
            end
            
            if ~strcmp(prv_drv_name, drv.name)
                L.info('OutputPort::setDriver', sprintf('Driver set [%s] -> [%s]', prv_drv_name, drv.name));
            end
        end
        
        function disp(obj)
            setting = obj.getCurrentSetting();
            infoStr = sprintf('Present Settings of [%s] Port:', obj.name);
            fprintf('%s\n%s\n', infoStr, repmat('-', 1, length(infoStr)));
            disp(struct2table(setting));
            
            if isempty(obj.driver)
                fprintf('Driver of Port [%s] is not configured.\n\n', obj.name);
            else
                fprintf('Port [%s] is controlled by Driver [%s].\n\n', obj.name, obj.driver.name);
                disp(obj.driver);
            end
        end
    end
    
    %%
    methods (Abstract)
        setDC(obj, value)
        setAC(obj, varargin)
        setAWG(obj, waveform, varargin)
        val = getDC(obj);
    end
end

